import java.util.Random;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 逆袭人生
 * Date: 2024-07-02
 * Time: 15:35
 */
public class Demon2 {
    public static void main(String[] args) {
        Random random = new Random();
        int randNum = random.nextInt(100);//[0-100)——>[0-100)+1-->[1-101)
        System.out.println("生成的随机数字："+randNum);
        Scanner scanner = new Scanner(System.in);
        while (true) {
            System.out.println("请输入你要猜的数字：");
            int num =scanner.nextInt();
            if (num > randNum) {
                System.out.println("猜大了！");
            } else if (num == randNum) {
                System.out.println("猜对了！");
                break;
            } else {
                System.out.println("猜小了！");
            }

        }


    }
    public static void main1(String[] args) {
        Scanner scanner = new Scanner(System.in);
        //读取多个数字
        while (scanner.hasNextInt()) {
            int a = scanner.nextInt();
            System.out.println(a);
            //读取多个字符串
            //输入的终止ctrl+d
            while (scanner.hasNextLine()) {
                String b = scanner.nextLine();
                System.out.println(b);
            }
        }
    }
}
